// ignore_for_file: deprecated_member_use
import 'package:flutter/material.dart';
import 'package:wallpaper/components/button/normal_button.dart';
import 'package:wallpaper/components/my_tags.dart';

class FilterItems extends StatelessWidget {
  final String order;
  final String ratioSelected;
  final String categories;
  final String purity;
  final ValueChanged<String> changeOrder;
  final ValueChanged<String?> changeRatioSelected;
  final ValueChanged<String> changeCategories;
  final ValueChanged<String> changePurity;
  final Function conditionalQuery;
  final TextEditingController ratioController;
  const FilterItems({
    super.key,
    required this.order,
    required this.ratioSelected,
    required this.categories,
    required this.purity,
    required this.changeOrder,
    required this.changeRatioSelected,
    required this.changeCategories,
    required this.changePurity,
    required this.conditionalQuery,
    required this.ratioController,
  });

  @override
  Widget build(BuildContext context) {
    List orderOptions = [
      ['desc', '降序'],
      ['asc', '升序'],
    ];

    List ratioOptions = [
      ['', '全部比例'],
      ['9x16', '9x16'],
      ['9x20', '9x20'],
      ['9x21', '9x21'],
      ['16x9', '16x9'],
      ['customize', '自定义'],
    ];

    List categoriesOptions = [
      ['100', '常规'],
      ['101', '动漫'],
      ['111', '人物'],
    ];

    List purityOptions = [
      ['100', '安全'],
      ['110', '模糊'],
      ['111', '成人'],
    ];
    final theme = Theme.of(context).colorScheme;
    return Container(
      margin: EdgeInsets.only(top: 50, bottom: 20, left: 15, right: 15),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(5),
      ),
      child: Column(
        children: [
          Expanded(
              child: ListView(
            children: [
              Column(
                spacing: 20,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  //  order, '排序', orderOptions, changeOrder, theme
                  MyTags(
                    groupValue: order,
                    title: '排序',
                    onChanged: changeOrder,
                    options: orderOptions,
                    theme: theme,
                  ),
                  MyTags(
                    groupValue: ratioSelected,
                    title: '比例',
                    onChanged: changeRatioSelected,
                    options: ratioOptions,
                    theme: theme,
                  ),
                  MyTags(
                    groupValue: categories,
                    title: '分类',
                    onChanged: changeCategories,
                    options: categoriesOptions,
                    theme: theme,
                  ),
                  MyTags(
                    groupValue: purity,
                    title: '限制',
                    onChanged: changePurity,
                    options: purityOptions,
                    theme: theme,
                  ),
                  // ratioController
                  Text(
                    '自定义比例 , 例如: 16x9',
                    style: TextStyle(color: Colors.white),
                  ),
                  TextField(
                    controller: ratioController,
                    style: TextStyle(color: Colors.white), // 设置文本颜色为白色
                    cursorColor: Colors.white, // 设置光标颜色为白色
                    decoration: InputDecoration(
                      hintText: '自定义比例',
                      fillColor: Colors.white.withOpacity(0.2),
                      filled: true,
                      contentPadding: EdgeInsets.symmetric(
                          vertical: 8.0, horizontal: 10.0), // 调整内部填充以减小高度
                      isDense: true, // 使字段更紧凑
                      border: OutlineInputBorder(
                        borderRadius: BorderRadius.circular(5),
                        borderSide: BorderSide.none,
                      ),
                      hintStyle: TextStyle(
                          color: Colors.white.withOpacity(0.5)), // 设置提示文本颜色
                    ),
                  ),
                ],
              ),
            ],
          )),
          NormalButton(
              title: '搜素',
              radius: 3,
              bgColor: Colors.white.withOpacity(0.2),
              onPressed: () {
                conditionalQuery();
                Navigator.pop(context);
              })
        ],
      ),
    );
  }
}
